package com.shuai.test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadTest2 {
    public static void main(String[] args) {
        final Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程开始了："+Thread.currentThread().getName());
            }
        },"T1");
        final Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {

                try {
                    t1.join(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("线程开始了："+Thread.currentThread().getName());
            }
        },"T2");
        final Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {

                try {
                    t2.join(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("线程开始了："+Thread.currentThread().getName());
            }
        },"T3");
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.submit(t1);
        executor.submit(t2);
        executor.submit(t3);
        executor.shutdown();
    }
}
